﻿function showMyDesign(){
	document.getElementById("myDesignTable").style.display="";
	document.getElementById("myOrderTable").style.display="none";
}
function myDesign(){
	document.getElementById("myDesignTable").style.display="";
	document.getElementById("myOrderTable").style.display="none";
	document.getElementById("friend_content_right").style.display="none";
}
function showMyOrder(){
	if(document.getElementById("hiddenflag").value==0){
		document.getElementById("hiddenflag").value=1;
		
		$.getJSON("ShowMyOrder.action",function(data){
			var orderTable=document.getElementById("myOrderTable");
			$.each(data.ordersList,function(index,value){
				var div_all=document.createElement("div");
				var div_pic=document.createElement("div");
				div_pic.setAttribute("class", "shoppingCar_right_pic");
				div_pic.setAttribute("style", "float:left");
				var picture=document.createElement("img");
				picture.setAttribute("src", value.orderPic);
				picture.setAttribute("width", "200px");
				picture.setAttribute("height", "200px");
				div_pic.appendChild(picture);
				div_all.appendChild(div_pic);
				var div_text=document.createElement("div");
				div_text.setAttribute("class", "shoppingCar_right_pic");
				div_text.setAttribute("style", "font-size:12px");
				var d1=document.createElement("div");
				d1.innerHTML="主题："+value.orderTheme;
				div_text.appendChild(d1);
				var d2=document.createElement("div");
				d2.innerHTML="编号："+value.orderId;
				div_text.appendChild(d2);
				var d3=document.createElement("div");
				d3.innerHTML="价格："+value.orderTotalPrice;
				div_text.appendChild(d3);
				var d4=document.createElement("div");
				d4.innerHTML="数量："+value.orderProductsCount;
				div_text.appendChild(d4);
				var d5=document.createElement("div");
				d5.innerHTML="户名："+value.orderName;
				div_text.appendChild(d5);
				var d6=document.createElement("div");
				d6.innerHTML="电话："+value.orderMobilePhone;
				div_text.appendChild(d6);
				var d7=document.createElement("div");
				d7.innerHTML="地址："+value.orderAddress;
				div_text.appendChild(d7);
				div_text.appendChild(document.createElement("br"));
				var d8=document.createElement("div");
				d8.innerHTML="设计时间："+value.orderTime_bak;
				div_text.appendChild(d8);
				var d9=document.createElement("div");
				d9.innerHTML="物流信息："+value.orderFreight;
				div_text.appendChild(d9);
				var d10=document.createElement("div");
				d10.innerHTML="备注："+value.orderContent;
				div_text.appendChild(d10);
				var d11=document.createElement("div");
				
				if(value.orderState==0){
					var b1=document.createElement("input");
					b1.setAttribute("type", "button");
					b1.setAttribute("value", "去付款");
					b1.setAttribute("style", "border:0;background-color:#94b8e9;");
					b1.setAttribute("onclick", "goShop("+value.orderId+")");
					d11.appendChild(b1);
					var f1=document.createElement("font");
					f1.setAttribute("style", "color:white;visibility:hidden");
					f1.appendChild(document.createTextNode("00000000"));
					d11.appendChild(f1);
				}
				if(value.orderState==1){
					var b2=document.createElement("input");
					b2.setAttribute("type", "button");
					b2.setAttribute("value", "已付款");
					b2.setAttribute("style", "border:0;background-color:#94b8e9;");
					b2.setAttribute("disabled", "disabled");
					d11.appendChild(b2);
				}
				if(value.orderState==2){
					var b3=document.createElement("input");
					b3.setAttribute("type", "button");
					b3.setAttribute("value", "已发货");
					b3.setAttribute("style", "border:0;background-color:#94b8e9;");
					b3.setAttribute("disabled", "disabled");
					d11.appendChild(b3);
				}
				if(value.orderState==3){
					var b4=document.createElement("input");
					b4.setAttribute("type", "button");
					b4.setAttribute("value", "交易成功");
					b4.setAttribute("style", "border:0;background-color:#94b8e9;");
					b4.setAttribute("disabled", "disabled");
					d11.appendChild(b4);
				}
				if(value.orderState!=0){
					d11.appendChild(document.createTextNode(" "));
					var b5=document.createElement("input");
					b5.setAttribute("type", "button");
					b5.setAttribute("value", "再购买");
					b5.setAttribute("style", "border:0;background-color:#94b8e9;");
					b5.setAttribute("onclick", "repayment("+value.orderId+")");
					d11.appendChild(b5);
				}
				var f2=document.createElement("font");
				f2.setAttribute("style", "color:white;visibility:hidden");
				f2.appendChild(document.createTextNode("00000000"));
				d11.appendChild(f2);
				if(value.isShare==0){
					var b6=document.createElement("input");
					b6.setAttribute("type", "button");
					b6.setAttribute("value", "去分享");
					b6.setAttribute("style", "border:0;background-color:#94b8e9;");
					b6.setAttribute("onclick", "gotoShare("+value.orderId+")");
					d11.appendChild(b6);
				}
				if(value.isShare==1){
					var b7=document.createElement("input");
					b7.setAttribute("type", "button");
					b7.setAttribute("value", "已分享");
					b7.setAttribute("style", "border:0;background-color:#94b8e9;");
					b7.setAttribute("disabled", "disabled");
					d11.appendChild(b7);
				}
				div_text.appendChild(d11);
				div_all.appendChild(div_text);
				orderTable.appendChild(div_all);
				orderTable.appendChild(document.createElement("br"));
			});
		});
		
	}
	document.getElementById("myDesignTable").style.display="none";
	document.getElementById("myOrderTable").style.display="";
}
function repayment(id){
	window.location.href="showShoppingCar.action?ordersId="+id+"&f=1";
}
function checkAll(){
	var obj = document.getElementById("checkAllbox");
	var cb1=document.getElementsByName("checkbox_payment");
	if(obj.checked){
		for(var i=0;i<cb1.length;i++){
			cb1[i].checked=true;
		}
	}else{
		for(var i=0;i<cb1.length;i++){
			cb1[i].checked=false;
		}
	}
}
function deleCustom(id){
	window.location.href="deleCustom.action?customId="+id;
}
function showCustom(id){
	window.location.href="showCustom.action?customId="+id;
}
function payment(){
	var flag=0;
	var a=document.getElementsByName("checkbox_payment");
	var a2="";
	for(var i=0;i<a.length;i++){
		if(a[i].checked){
			flag=1;
			a2=a2+a[i].value+",";
		}
	}
	if(flag==1){
		window.location.href="showShoppingCar.action?customId="+a2+"&f=0";
	}else{
		alert("请先选中将要付款的设计。");
		return;
	}
}
function checkNumber(){
	var number=document.getElementById("buynumber").value;
	if(!(/^\d{1,}$/.test(number))){
		document.getElementById("buynumber").value="1";
		alert("请输入数字!");
	}
}
function goShop(id){
	window.location.href="showShoppingCar.action?ordersId="+id+"&f=1";
}
function toNewCustom(){
	window.location.href="showCustom.action";
}
function gotoShare(id){
	window.location.href="Sharepageedit.action?_id="+id;
}
function searchMyRecoFriends(){
	var value=$("#searchinputtext").val();
	if(value==null||value==''){
		alert("请输入要查询的车主品牌或车主姓名！");
	}else{
		$.getJSON("searchRecoFriends.action",{
			"value":value
		},function(data){
			$("#child4").empty();
			var hd=document.getElementById("child4");
			$.each(data.userhots,function(index,value){
				var div_img=document.createElement("div");
				div_img.setAttribute("class","my_order_mydesign_hisfriendinfo_child_username_img");
				var a_img=document.createElement("a");
				a_img.setAttribute("href","");
				a_img.innerHTML="<img src='"+value.userFace+"' height='45px' width='45px'/>";
				div_img.appendChild(a_img);
				var div_detail=document.createElement("div");
				div_detail.setAttribute("class","my_order_mydesign_hisfriendinfo_child_username_detail");
				var div_name=document.createElement("div");
				div_name.setAttribute("class","my_order_mydesign_hisfriendinfo_child_username_detail_name");
				var div_username=document.createElement("div");
				div_username.setAttribute("class","friend_child_name");
				div_username.setAttribute("id","username");
				var text_username=document.createTextNode(value.userName);
				div_username.appendChild(text_username);
				div_name.appendChild(div_username);
				div_detail.appendChild(div_name);
				
				var div_zhishu=document.createElement("div");
				div_zhishu.setAttribute("class", "my_order_mydesign_hisfriendinfo_child_username_detail_renqi");
				div_zhishu.innerHTML="指数：(<a href='' id='zhishu'>"+value.usersHot+"</a>)";
				div_detail.appendChild(div_zhishu);
				
				hd.appendChild(div_img);
				hd.appendChild(div_detail);
			});
		},"json");
	}
}
